<template>
    <div class="mine">
        <van-tabs v-model="active" style="margin-bottom: 5px" @click="tabChange">
            <van-tab title="购物"></van-tab>
            <van-tab title="收益"></van-tab>
            <van-tab title="提现"></van-tab>
            <van-tab title="系统"></van-tab>
        </van-tabs>
        <div>
            <van-list
                    v-model="config.loading"
                    :finished="config.finished"
                    finished-text="没有更多了"
                    @load="write"
                    :immediate-check="false"
            >
            <div class="pd-12-16 border-bottom" v-for="(item,index) in list" :key="index">
                <div class="flex-row justify-content-between">
                    <div class="font-14">{{item.type_name}}</div>
                    <div>{{item.create}}</div>
                </div>
                <div class="mt5 font-grey">{{item.remark}}</div>
            </div>
            </van-list>
        </div>
    </div>
</template>
<script>
    export default {
        name: "Log",
        data() {
            return {
                list: [],
                active: 0,
                url: {
                    write: this.axiosUrl + 'users/write'
                },
                config: {
                    loading: false,
                    finished: false,
                    pageIndex: 1,
                    limit: 10,
                    time: '',
                }
            }
        },
        components: {},
        mounted() {
            this.write()
            this.$wxConfig.share(this.$route.path)
        },
        methods: {
            write() {
                let _this = this
                _this.config.loading = true
                _this.time = new Date().getTime()
                let e = new Date().getTime()
                setTimeout(() => {
                    if (_this.time == e) {
                        _this.$http.post(_this.url.write, {
                            class: _this.active * 1 + 1,
                            pages: _this.config.pageIndex,
                            limit: _this.config.limit
                        }, (res) => {
                            _this.list = _this.list.concat(res)
                            _this.config.pageIndex++
                            if (res.length < _this.config.limit) {
                                _this.config.finished = true
                            } else {
                                _this.config.finished = false
                            }
                            _this.config.loading = false
                        })
                    }
                }, 300)
            },
            tabChange(){
                let _this = this
                _this.list = []
                _this.config.finished = false
                _this.config.pageIndex = 1
                _this.write()
            }
        }
    }
</script>
<style lang="stylus" scoped>
    .van-tabs__line {
        background-color #ff6f00
    }

    .mine-list
        margin 16px
        background white
        border-radius 8px
        overflow hidden

</style>
